<?php

namespace App\Modules\Admin\Services\System;

use App\Modules\Admin\Entities\System\SysAraeModel;
use App\Modules\Admin\Services\BaseService;
use Illuminate\Support\Facades\DB;

class SystemCityService extends BaseService
{
    public function __construct(SysAraeModel $dictModel)
    {
        $this->model = $dictModel;
    }
    public function lists(array $params) : array
    {
        $params['where_callback'] = function ($query) use ($params) {
            $request = request();
            if (!empty($dict_type = $request->input('dictType', ''))) {
                $query->where('company_name',$dict_type);
            }
        };
        $lists = parent::lists($params);
        return $lists; // TODO: Change the autogenerated stub
    }



    public function create(array $params)
    {
        DB::beginTransaction();
        try{
            $this->detail = parent::create($params); // TODO: Change the autogenerated stub
            DB::commit();
            return $this->detail['id'];
        }catch (Exception $e){
            DB::rollBack();
            return false;
        }
    }
    public function getSelectLists($request)
    {

        return $this->model->getSelectLists();
    }
    public function getSelectCityLists($request)
    {

        return $this->model->getSelectCityLists($request);
    }
    public function getParentLists($request)
    {

        return $this->model->getParentLists($request);
    }
    public function getApiParentLists($request)
    {
        return $this->model->getCacheTree();
    }
}
